<?php

namespace app\admin\controller\business;

use app\common\controller\Backend;

class Order extends Backend
{
    protected $model = null;
    //关联查询的意思
    protected $relationSearch = true;
    public function __construct()
    {
        parent::__construct();
        $this->model = model("Subject.Order");
    }
    public function index($ids = NULL)
    {
        if ($this->request->isAjax()) {
            //接收参数
            list($where, $sort, $order, $offset, $limit) = $this->buildparams();

            $total = $this->model
                ->with(['business','subject'])
                ->where($where)
                ->where('busid', $ids)
                ->order($sort, $order)
                ->count();

            $list = $this->model
                ->with(['business','subject'])
                ->where($where)
                ->where('busid', $ids)
                ->order($sort, $order)
                ->limit($offset, $limit)
                ->select();

            //返回json数据
            $result = ['total' => $total, 'rows' => $list];

            return json($result);
        }
        return $this->view->fetch();
    }
}
